package BasicGrammar.Basic;

import java.util.Random;
import java.util.Scanner;

public class day_0918 {
    public static void main4(String[] args) {

    }
    public static void main1(String[] args) {
        //辗转相除法：
        int a = 12;
        int b = 18;
        int c = a % b;
        while(c!= 0){
            a = b;
            b = c;
            c = a % b;
        }
        System.out.println(b);
    }

    public static void main2(String[] args) {
        Random random = new Random();
        int a = random.nextInt(1000);
        System.out.println(a);
        Scanner i = new Scanner(System.in);
        int b = i.nextInt();
        System.out.println(b);
    }

    public static void main3(String[] args) {
        Random i =  new Random();
        int a = i.nextInt(10);

        Scanner j = new Scanner(System.in);

        while (true) {
            System.out.print("请输入：");
            int b = j.nextInt();
            if (a > b) {
                System.out.println("猜小了");
            } else if (a == b) {
                System.out.println("猜对了");
                break;
            } else {
                System.out.println("猜大了");
            }
        }

        int c = j.nextInt();
        System.out.println(c);
        //“i”像是一个代行者的意思，替身，傀儡？
    }

    public static void main5(String[] args) {
        int n = 5;
        int ret = factor(n);
        System.out.println("ret = " + ret);
    }
    public static int factor(int n) {
        if (n == 1) {
            return 1;
        } else {
            return n * factor(n - 1);
        }
    }// factor
    //调⽤函数⾃⾝
   // 执⾏结果
    public static int main6(int n) {
        if (n < 10){
            return n;
        }else{
            return (n % 10 )+ (main6(n/10));
        }
    }
    public static void main(String[] args) {
        int a = main6(1729);
        System.out.println(a);
    }

}
